<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<%@ taglib prefix="his_fns" uri="/WEB-INF/tlds/his_fns.tld" %>

<div class="app">
    <section class="layout">
        <section class="main-content col-lg-12" id="applicationLeftDiv">
            <div class="content-wrap">
                <div class="wrapper" style="bottom: 50px;">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#">申请单列表</a>
                        </li>
                    </ul>
                    <section class="panel panel-default">
                        <div class="panel-body">
                            <div class="table-responsive no-border">
                                <div class="datatable-top">
                                    <div class="pull-left">
                                        <form:form id="searchForm" modelAttribute="expProvideApplication"
                                                   onsubmit="return loadDivForm('mainCenterDiv','searchFormDict','${ctx}/csm/expStock/index');"
                                                   method="post" class="form-inline">
                                            <div class="form-group">
                                                <label class=" control-label">发放单位：</label>
                                                <form:select path="storageOut" id="storageOut" htmlEscape="false" class="form-control" maxlength="1" data-parsley-required="true">
                                                    <form:options items="${his_fns:getByStorageLevel('1')}" itemLabel="storageName" itemValue="storageCode" htmlEscape="false" />
                                                </form:select>
                                            </div>
                                            <div class="form-group">
                                                <input id="btnSubmit" class="btn btn-primary" type="button" onclick="saveProvideApplication()" value="保存"/>
                                                <input id="addExp" class="btn btn-primary" type="button" value="增加" onclick="addExpList()"/>
                                            </div>
                                        </form:form>
                                    </div>
                                </div>
                                <form id="saveProvideApplication" action="${ctx}/csm/expProvideApplication/save" method="post" class="form-inline">
                                    <table id="contentTable" class="table table-bordered table-striped mg-t datatable">
                                        <thead>
                                        <tr>
                                            <th hidden>infoId</th>
                                            <th hidden>发放单位</th>
                                            <th>编码</th>
                                            <th>名称</th>
                                            <th hidden>规格</th>
                                            <th hidden>单位代码</th>
                                            <th hidden>单位</th>
                                            <th hidden>包装数量</th>
                                            <th>规格</th>
                                            <th hidden>包装单位代码</th>
                                            <th>单位</th>
                                            <th hidden>厂家ID</th>
                                            <th>生产厂家</th>
                                            <th>申请数量</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                    </table>
                                </form>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </section>
        <section class="main-content col-lg-4" style="display: none" id="applicationRightDiv">
            <div class="content-wrap" id="rigthCenterDiv">
            </div>
        </section>
    </section>
</div>

<script type="text/javascript">
    function removeList(btn) {
        $(btn).parent().parent().remove();
    }

    //保存
    function saveProvideApplication() {
        $("#saveProvideApplication").ajaxSubmit({
            success: function (data) {
                if (data.code == 'success') {
                    toastr.success(data.data);
                    loadDiv('applicationLeftDiv', '${ctx}/csm/expProvideApplication/index');
                } else {
                    toastr.error(data.data);
                }
            },
            error: function (data) {
                toastr.error(data.data);
            }
        });
    }

    function addExpList() {
        document.getElementById('storageOut').disabled = true;
        $("#applicationLeftDiv").attr("class", "main-content col-lg-8");
        $("#applicationRightDiv").show('normal');
        return loadDiv('rigthCenterDiv', '${ctx}/csm/expProvideApplication/form');
    }
</script>